package net.apexes.demo.codegen.dslite.qvar;

import net.apexes.demo.codegen.dslite.entity.GoodsBase;
import net.apexes.demo.codegen.dslite.qvar.base.QEntityBase;
import net.wafo.dslite.core.info.ForeignKey;
import net.wafo.dslite.core.info.Index;

import net.wafo.dslite.core.dsl.*;

/**
 * QGoodsBase is a DSLite query type for GoodsBase
 * @see GoodsBase
 */
public class QGoodsBase extends QEntityBase<GoodsBase> {

    public static final QGoodsBase $ = new QGoodsBase("GOODS_BASE");

    public final StringColumn name = varchar("NAME", 32).field("name").notNull().build();

    public final StringColumn quickCode = varchar("QUICK_CODE", 8).field("quickCode").notNull().build();

    public final StringColumn measureType = varchar("MEASURE_TYPE", 1).field("measureType").notNull().build();

    public final StringColumn goodsGroupId = varchar("GOODS_GROUP_ID", 22).field("goodsGroupId").notNull().build();

    public final StringColumn templateId = varchar("TEMPLATE_ID", 22).field("templateId").notNull().build();

    public class Indexs {

        public final Index constraintIndex30 = index("CONSTRAINT_INDEX_30").column(goodsGroupId).build();

        public final Index ixGoodsBaseStatusGroup = index("IX_GOODS_BASE_STATUS_GROUP").column(statusFlag).column(goodsGroupId, true).build();

        public final Index primaryKey30 = index("PRIMARY_KEY_30").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public class ForeignKeys {

        public final ForeignKey constraint301 = foreignKey(goodsGroupId, "GOODS_GROUP", "ID");

    }

    public final ForeignKeys fk = new ForeignKeys();

    public QGoodsBase(String tableName) {
        super(GoodsBase.class, tableName);
    }

    @Override
    public GoodsBase newEntity() {
        return new GoodsBase();
    }

    @Override
    public Object getFieldValue(GoodsBase entity, String fieldName) {
        switch (fieldName) {
            case "name":
                return entity.getName();
            case "quickCode":
                return entity.getQuickCode();
            case "measureType":
                return entity.getMeasureType();
            case "goodsGroupId":
                return entity.getGoodsGroupId();
            case "templateId":
                return entity.getTemplateId();
            default:
                return super.getFieldValue(entity, fieldName);
        }
    }

    @Override
    public void setFieldValue(GoodsBase entity, String fieldName, Object value) {
        switch (fieldName) {
            case "name":
                entity.setName((java.lang.String) value);
                break;
            case "quickCode":
                entity.setQuickCode((java.lang.String) value);
                break;
            case "measureType":
                entity.setMeasureType((java.lang.String) value);
                break;
            case "goodsGroupId":
                entity.setGoodsGroupId((java.lang.String) value);
                break;
            case "templateId":
                entity.setTemplateId((java.lang.String) value);
                break;
            default:
                super.setFieldValue(entity, fieldName, value);
                break;
        }
    }

}

